You are here: Building the Model: General Elements > Pre-defined Tank Subroutines > Examples of Tank Control Logic > Selecting from Multiple Input or Output Tanks
To enable one or more tanks to select from several input or output tanks, use the pre-defined subroutine Tank_SelectInput or Tank_SelectOutput (see subroutine descriptions). ProModel bases tank selection on which tank is ready to transfer or receive and that has the same ProductType array value. You must list the tank selections together in the Location module.
For example, if TankX selects from among three input tanks (Tank1, Tank2, and Tank3) based on which input tank has waited the longest to discharge its contents, you would enter the following logic in the control subroutine defined for TankX:
Select from multiple tanks
Int SelectedTank
SelectedTank = Tank_SelectInput(TankX, Tank1, 3,
Tank_LongestBlocked, 0)
The first statement defines a local variable, SelectedTank, used to assign which tank you select. The second statement calls the SelectInput subroutine specifying that TankX is to select one of three tanks beginning with Tank1. Tank_LongestBlocked causes TankX to select the tank blocked the longest (i.e., tank is full or waiting). Entering 0 at the end prevents selecting a full tank. If no tank is full, the statement does not execute until one of the input tanks fills. With a tank ID assigned to SelectedTank, you can call a transfer subroutine to make the transfer.
For output tanks, you would define similar logic but include Tank_SelectOutput instead of Tank_SelectInput.